package Eyjafjalla.patch;

import Eyjafjalla.modcore.ClassEnum;
import Eyjafjalla.screens.SkinSelectScreen;
import basemod.ReflectionHacks;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.evacipated.cardcrawl.modthespire.lib.SpirePatch;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.screens.charSelect.CharacterSelectScreen;

public class SelectScreenPatch {
    public SelectScreenPatch(){

    }

    public static boolean isPuzzlerSelected() {
        return CardCrawlGame.chosenCharacter == ClassEnum.Eyjafjalla_CLASS && (Boolean) ReflectionHacks.getPrivate(CardCrawlGame.mainMenuScreen.charSelectScreen, CharacterSelectScreen.class, "anySelected");
    }

    @SpirePatch(
            clz = CharacterSelectScreen.class,
            method = "render"
    )
    public static class RenderButtonPatch {
        public RenderButtonPatch() {
        }

        public static void Postfix(CharacterSelectScreen _inst, SpriteBatch sb) {
            if (SelectScreenPatch.isPuzzlerSelected()) {
                SkinSelectScreen.Inst.render(sb);
            }

        }
    }

    @SpirePatch(
            clz = CharacterSelectScreen.class,
            method = "update"
    )
    public static class UpdateButtonPatch {
        public UpdateButtonPatch() {
        }

        public static void Prefix(CharacterSelectScreen _inst) {
            if (SelectScreenPatch.isPuzzlerSelected()) {
                SkinSelectScreen.Inst.update();
            }

        }
    }
}
